<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.qijia.travel.app.*"  %>
<%@ page import="com.qijia.travel.domain.*"  %>
<%@ page import="com.qijia.travel.vo.*"  %>
<%@ page import="com.qijia.travel.helper.*"  %>
<%@ page import="com.qijia.travel.common.*"  %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
		String path = request.getContextPath();
		String basePath = request.getScheme() + "://"+ request.getServerName() + ":"+ request.getServerPort() + path + "/";

		Guide guide = (Guide) session.getAttribute(Constants.USER_KEY);

		request.setCharacterEncoding("UTF-8");
		GuideManager manager = new GuideManager();
		GuideVO vo = (GuideVO) ObjectHelper.ConvertURLRequsetMapToObj(request.getParameterMap(), GuideVO.class);
		if (null == vo.getStartDate()) {
			vo.setStartDate(DateHelper.getShortNowTime());
		}
			vo.setOrderBy(" guide_seq ");
			vo.setACode(1);
			PageResult pageObj = manager.selectGuideList(vo);
			TouristManager tManager = new TouristManager();
%>
<c:set var="vo" value="<%=vo%>" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<title>后台管理平台--旅游网 </title>
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/layout.css" />
<script language="javascript" type="text/javascript" src="<%=basePath%>js/displayLayer.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>js/calendar.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>js/selectall.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>js/trchgcolor.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>js/listOrder.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>js/popupdiv_shim.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>js/ajaxPopup.js"></script>
<link rel="stylesheet" type="text/css" href="<%=basePath%>js/ymPrompt/skin/qq/ymPrompt.css" />
<script type="text/javascript" src="<%=basePath%>js/ymPrompt/ymPrompt.js"></script>
</head>
<body>
<div id="wrapper">
    <!--头部菜单开始-->
    <jsp:include page="../common/TopMenu.jsp"></jsp:include>
    <!--头部菜单结束-->
	<div id="BreadCrumb">我的位置：导游信息管理 &gt; 导游列表</div>
	<div id="REC_content">
	    <fieldset id="JobsMgr" class="mainField">
		    <legend><span class="title">导游列表</span></legend>
			<div class="innerCon">
			    <form name="PositionMgrForm" action="" method="post">
				<!--表头搜索条开始-->
				<div class="mainSearchBox">
				<table width="100%" cellpadding="0" cellspacing="0" border="0" class="editTab">
					<tr height="35">
						<td width="80" class="title">所属团队</td>
						<td width="300">
						   <input type="hidden" name="treamId" id="Departments" value="<%=vo.getTreamId() == null ? "" : vo.getTreamId()%>"/>
						   <input type="hidden" name="treamName" id="DepartmentsName" value="<%=null == vo.getTreamName() ? "全部" : vo.getTreamName()%>" />
						   <input type="button" class="buttonPopupDiv270" value="<%=vo.getTreamName() == null ? "全部" : vo
							.getTreamName()%>" id="buttonSelDep" name="buttonSelDep" vHiddenId="Departments" nHiddenId="DepartmentsName" nWidth="350" maxWidth="450" maxHeight="200" modTitle="所属团队" modTxtNull="全部" cache4get="no" />
						</td>
						<td width="80" class="title">关键字</td>
						<td width="300" class="title">
						<select name="searchCode">
							<option value="1" <%if (null != vo.getSearchCode() && vo.getSearchCode() == 1)out.print("selected");%>>导游姓名</option>
							<option value="2" <%if (null != vo.getSearchCode() && vo.getSearchCode() == 2)out.print("selected");%>>状态名称</option>
							<option value="3" <%if (null != vo.getSearchCode() && vo.getSearchCode() == 3)out.print("selected");%>>导游编号</option>
							<option value="8" <%if (null != vo.getSearchCode() && vo.getSearchCode() == 8)out.print("selected");%>>导游类型</option>
							<option value="10" <%if (null != vo.getSearchCode() && vo.getSearchCode() == 10)out.print("selected");%>>所属一线</option>
						</select> 
						<input type="text" name="searchKeyword" value="<%=vo.getSearchKeyword() == null ? "" : vo.getSearchKeyword()%>" size="25" /></td>
						<td width="140"><input type="submit" name="searchButton" class="newSearchButton" value="查询" /></td>
					</tr>
					<tr height="35">
						<td width="80" class="title">月份</td>
						<td width="300" colspan="4">
						   <input type="text" id="startImg" onclick="fPopCalendar(document.getElementById('startImg'),document.getElementById('startImg'));return false;" name="startDate" size="10" readonly="readonly" value="<%=vo.getStartDate() == null ? "" : vo
							.getStartDate()%>" onkeydown="iniTxt_OnKeydown(event,this);" />
						   <c:if test=""> </c:if>
						   <input type="checkbox" value="true" name="Complete" <%if (vo.getComplete())
						out.print("checked=checked");%>/>完整查询
						</td>
					</tr>
					<tr id="moresearchCon" style="display:none">
					</tr>
				</table>
				</div>
				<!--表头搜索条开始-->
				
			    <!-- begin tab -->
			    <div class="topControl clearfix">
				    <div id="JobsMgrTabCon" class="itemTabCon">
					    <ul id="JobsMgrTabs" class="itemTabs">
							<li id="onlineTab" class="focus"><a href="<%=basePath%>baseInfo/guideManage.jsp" onfocus="this.blur()">导游状态管理</a></li>
							<li id="onlineTab" class="blur"><a href="<%=basePath%>work/tourist.jsp" >排团管理</a></li>
							<li id="onlineTab" class="blur"><a href="<%=basePath%>work/consumption.jsp" onfocus="this.blur()">团消费管理</a></li>
						    <li id="onlineTab" class="blur"><a href="<%=basePath%>work/expenditure.jsp">公司收支管理</a></li>
					    </ul>
				    </div>
			    </div>
			    <!-- end tab -->
				
				<div id="mainListCon">
						<div class="infoCon">
							<div class="info">符合搜索条件的导游信息共有 <span class="num" id="guideCnt"><%=pageObj.getRowCnt()%></span> 条</div>
						</div>
						<div class="tableCon">
							 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="listTab" id="tableData">
							 <tr class="tabHead">
								 <td class="blankTd"></td>
								 <td width="5%" class="centerAlign" nowrap>排序</td>
								 <td width="8%" class="centerAlign" nowrap>姓名</td>
								 <td width="8%" class="centerAlign" nowrap>所属一线</td>
								 <td width="8%" class="centerAlign" nowrap>导游能力</td>
								 <td width="5%" class="centerAlign" nowrap>导游类型</td>
								 <td width="5%" class="centerAlign" nowrap>性别</td>
								 <td width="10%" class="centerAlign" nowrap>手机号</td>
								 <td width="10%" class="centerAlign" nowrap>联系电话</td>
								 <td width="5%" class="centerAlign" nowrap>出团数</td>
								 <td width="24%" class="centerAlign" nowrap>状态</td>
								 <td width="10%" class="centerAlign" nowrap>注册日期</td>
								 <td width="10%" class="centerAlign" nowrap>最近登录日期</td>
							 </tr>
							 
							 <%
							 	int i = 0 + pageObj.getStartRow();
							 	for (Object obj : pageObj.getPageList()) {
							 		String bgColor = "lightgreen";
							 		i++;
							 		Guide guideObj = (Guide) obj;
							 		if (guideObj.getStatusName() != null) {
							 			if ("请假".equals(guideObj.getStatusName().trim())) {
							 					bgColor = "#FF9999";
							 			} else if ("待命".equals(guideObj.getStatusName().trim())) {
							 					bgColor = "lightgreen";
							 			} else if ("在团上".equals(guideObj.getStatusName().trim())) {
							 					bgColor = "yellow";
							 			} else if ("已预定".equals(guideObj.getStatusName().trim())) {
							 					bgColor = "lightyellow";
							 			}
							 		}
							 %>
							      <tr class='<%=i % 2 == 0 ? "list1" : "list2"%>'>
                                  <td class='tdCheckbox'>
                                     <input type='checkbox' id="<%=guideObj.getGuideId()%>" name='PositionID' value='1' onclick='unChkSelectAll("chkall")' /></td>
                                  <td class='centerAlign' nowrap=nowrap><%=guideObj.getGuideSeq() == null ? "" : guideObj.getGuideSeq()%></td>
                                  <td class='centerAlign' style='word-break:break-all;word-wrap:break-word;'>
                                    <a href='javascript:ymPrompt.win("newGuide.jsp?guideId=<%=guideObj.getGuideId()%>",480,400,"修改信息",closeWin,null,null,true)'>
                                     <%=guideObj.getGuideName()%>
                                    </a>
                                  </td>
                                  <td class='centerAlign' style='word-break:break-all;word-wrap:break-word;'>
                                      <%=null==guideObj.getBelongTo()?"无":guideObj.getBelongTo()%>
                                  </td>
                                  <td class='centerAlign'>
                                    <a href='javascript:ymPrompt.win("guideTream.jsp?guideId=<%=guideObj.getGuideId()%>",330,220,"修改所属团队",closeWin,null,null,true)'>
                                    <%=guideObj.getTreamName() == null ? "无": guideObj.getTreamName()%></a></td>
                                  <td class='centerAlign' nowrap="nowrap"><%
                                  	if (guideObj.getGuideType() != null&& guideObj.getGuideType() == 1){
                                  		out.print("一线");
                                  	}else{
                                  		out.print("二线");
                                  	}
                                  %></td>
                                  <td class='centerAlign' nowrap="nowrap"><%
                                  	if ("1".equals(guideObj.getGuideSex())){
                                  		out.print("男");
                                  	}else{
                                  		out.print("女");
                                  	}
                                  %></td>
                                  <td class='centerAlign' nowrap=nowrap><%=guideObj.getMobile() == null ? "" : guideObj.getMobile()%></td>
                                  <td class='centerAlign' nowrap=nowrap><%=guideObj.getPhone() == null ? "" : guideObj.getPhone()%></td>
                                  <td class='centerAlign' nowrap=nowrap>
                                  <%=tManager.countGuideGroupNum(guideObj.getGuideId(), vo)%></td>
                                  <td class='centerAlign' bgcolor='<%=bgColor%>' >
                                  <a href='javascript:ymPrompt.win("guideStatus.jsp?guideId=<%=guideObj.getGuideId()%>",330,220,"修改当前状态",closeWin,null,null,true)'>
                                  <%=guideObj.getStatusName() == null ? "待命" : tManager.getLastTouristTime(guideObj.getGuideId()) + guideObj.getStatusName()%></a></td>
                                  <td class='centerAlign' nowrap=nowrap><span class='deadline'>
                                  <%=guideObj.getRegDate() == null ? "" : DateHelper.parseToString(guideObj.getRegDate(),DateHelper.yyyyMMdd)%></span></td>
                                  <td class='centerAlign' nowrap=nowrap><span class='deadline'>
                                  <%=guideObj.getLoginDate() == null ? "" : DateHelper.parseToString(guideObj.getLoginDate(),DateHelper.yyyyMMdd)%></span></td>
                             </tr>
                             <%
                             	}
                             %>
                              <tr align="center">
								<td colspan="12">&nbsp;</td>
							</tr>
							 </table>
						</div>
						
						<!--BeginShowPage-->
						<div class="turnpageCon clearfix">
							 <!--@BeginCHECKALL-->
							 <div class="checkAll">
							   <input type="checkbox" name="chkall" value="1" onclick="ChkSelectAll('PositionID','chkall')" id="chkall" style="cursor:pointer" />
							   <label for="chkall" style="cursor:pointer"> 全选</label>
							   <input type="hidden" id="curPage" name="curPage" value="<%=vo.getCurPage()%>"/>
							 </div>
							 <!--@EndCHECKALL-->
							 <div class="turnpage" id="turnpage">
								<%=pageObj.getSimpleBar()%>
							 </div>
						</div>
						<!--EndShowPage-->
					    <div class="bottomControl">
						    <input type="button" value="注册新导游" class="genButton1" onclick="ymPrompt.win('newGuide.jsp',480,350,'新增导游',closeWin,null,null,true)" />&nbsp;
						     <%
						     	if (guide.getGuideType() != null && guide.getGuideType() == 1) {
						     %>
						    <input type="button" value="删除选中项" class="genButton1" onclick="deleteSelected()" />&nbsp;
						    <%
						    	}
						    %>
					    </div>
				</div>
				</form>
			</div>
		</fieldset>
	</div>
	<jsp:include page="../common/Foot.jsp"></jsp:include>
</div>
<script src="<%=basePath%>js/PaginatedTools.js"></script>
<script src="<%=basePath%>dwr/interface/guideManager.js"></script>
<script src="<%=basePath%>dwr/interface/treamManager.js"></script>
<script src="<%=basePath%>dwr/engine.js"></script>
<script src="<%=basePath%>js/jquery.js"></script>
<!--部门弹出窗口JS-->
<script language="javascript" type="text/javascript">
var showDept = function(e){
var ele=e.srcElement?e.srcElement:e.target;
var s=document.getElementById(ele.id);
var myDiv = document.createElement('div');
s.title = s.getAttribute('modTitle')||'';
myDiv.id = s.id + '_div';
myDiv.className = 'popupSearcher';
myDiv.style.width = 350 + 'px';
var subDiv = document.createElement('div');
subDiv.className = 'title';
subDiv.innerHTML = '<div style="float:left;">'+s.title+'：</div><div style="float:right;"><a href="javascript:hideCurrentPopup();">[关闭]</a></div>';
myDiv.appendChild(subDiv);
subDiv = document.createElement('div');
subDiv.className = 'content';
myDiv.appendChild(subDiv);
s.div = myDiv;
s.div_c = subDiv;
subDiv = document.createElement('div');
s.div_c.appendChild(subDiv);
s.div_t = subDiv;//fix IE7
s.div.onclick = function(event){var e = event?event:window.event;e.preventDefault?e.stopPropagation():(e.cancelBubble=true);};

if(s.offsetParent&&s.offsetParent.tagName.toLowerCase()!='html') s.offsetParent.appendChild(s.div);
	else document.body.appendChild(s.div);

getTreams(s.div_t);

s.div_t.innerHTML = '<div style="padding:5px;">请稍候...</div>';
var coord = getXY(s);
var x = coord.x;
var y = coord.y + parseFloat(s.offsetHeight);
switchVisibility(s.div.id,e,x,y);
};
function bingDept(){
  var buttonSelDep=document.PositionMgrForm.buttonSelDep;/*按钮名称*/
  myAttachEvent(buttonSelDep,'click',showDept);
}

bingDept();
function getTreams(obj){
   var deptStr="";
   treamManager.getTreamByExample(function(data){
      deptStr+="<p><div width='100%' style='cursor:pointer' onclick=setTream(0,'全部')>全部</div></p>";
      for(var i in data){
        deptStr+="<p><div width='100%' style='cursor:pointer' onclick=setTream('"+data[i].treamId+"','"+data[i].treamName+"')>"+data[i].treamName+"</div></p>";
      }
      obj.innerHTML = "<div style='padding:5px;'>"+deptStr+"</div>";
   });
}
function setTream(deptId,deptName){
  $("#buttonSelDep").val(deptName);
  if(deptId==0)
   $("#Departments").attr("value","0");
  else
  $("#Departments").val(deptId);
  $("#DepartmentsName").val(deptName);
  hideCurrentPopup();
}

 <%if (guide.getGuideType() != null && guide.getGuideType() == 1) {%>
function getCheckItems(){
 var guides;
 var first=0;
 $("input[name='PositionID']").each(function(idx){
   if(this.checked){
      if(first==0){
         guides=this.id;
         first=1;
      }else{
         guides+=","+this.id;
      }
   }
 });
 return guides;
}

function deleteSelected(){
 if(confirm("确定要删除掉选中的导游吗?")){
   guideManager.deleteGuides(getCheckItems(),function(data){
     alert("删除成功");
     window.location.reload();
   });
 }else
   return;
}
<%
}
%>
var errorHandle = function(err){
     alert(err);
};
dwr.engine.setErrorHandler(errorHandle); 

function formSubmit(curPage){
  //window.location.href="guideManage.jsp?curPage="+curPage;
  $("#curPage").val(curPage);
  document.PositionMgrForm.submit();
}
PaginatedTools.setCallBackFun(formSubmit);
function closeWin(){
}

</script>
</body>
</html>
